package com.baizhi.service.impl;

import com.baizhi.dao.UserDao;
import com.baizhi.entity.User;
import com.baizhi.service.UserService;

import java.util.List;

public class UserServiceImpl implements UserService {
    //定义一个dao接口类型的属性
    private UserDao userDao;
    //提供属性的set方法  Spring底层是通过set方法给对象属性赋值的

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public List<User> selectAll() {
        List<User> users = userDao.selectAll();
        return users;
    }

    @Override
    public void insertUser(User u) {
        userDao.insertUser(u);
        throw new RuntimeException("出现异常");
    }
}
